import org.utils.utils

def call(String jobName) {
    def business_name = utils.getEnv(jobName,0)
    def Make_Env = utils.getEnv(jobName,4)
    def cfg_text = libraryResource("${Make_Env}/${business_name}/${jobName}.yaml")
    def cfg = readYaml text: cfg_text
    def system_text = libraryResource("${Make_Env}/config/config.yaml")
    def system = readYaml text: system_text
    // def paramMap = paramBuild(jobName,cfg,system)
    echo "business_name: ${business_name}"
    echo "Make_Env: ${Make_Env}"
    echo "cfg_text: ${cfg_text}"
    echo "cfg: ${cfg}"
    echo "system_text: ${system_text}"
    echo "system: ${system}"
    // echo "{paramMap}"

    pipeline {
        agent any
        
        parameters {
            gitParameter branch: '', branchFilter: '.*', defaultValue: 'master', description: '选择将要构建的分支', name: 'branch', quickFilterEnabled: true, selectedValue: 'TOP', sortMode: 'DESCENDING_SMART', tagFilter: '*', type: 'PT_BRANCH_TAG', useRepository: 'https://gitee.com/xjz_git/word.git'
        }
        
        environment {
            GIT_REPO_URL = 'https://gitee.com/xjz_git/word.git'
            // CREDENTIALSID = 'c7bfb3a2-11ee-4229-b38b-d9895d77c97d'
        }
        
        stages {
            stage('检出代码') {
                steps {
                    checkout([
                        $class: 'GitSCM',
                        branches: [[name: params.branch.replace('origin/', '')]],
                        extensions: [],
                        userRemoteConfigs: [
                            [
                                url: env.GIT_REPO_URL,
                                // credentialsId: env.CREDENTIALSID 
                            ]
                        ]
                    ])
                }
            }
        }
    }
}